<?php
include("../pages/config.php");

/*$con = mysql_connect("localhost","root","M00nshine");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
*/
$q = $_GET["q"];
$sid = $_GET["sid"];

//mysql_select_db("occam_db", $con);

$result = mysql_query("SELECT * FROM port_info WHERE info_1 like '%$q%' OR info_2 like '%$q%' OR info_3 like '%$q%'
			ORDER BY blade_ip, port_num");
#$result = mysql_query("SELECT * FROM port_info WHERE info_1 like '%$q%'");

echo "<table width='100%' style='padding-right: 10px; padding-right: 10px;'>";
echo "<tr><th>Blade IP</th><th>Port</th><th>Info 1</th><th>Info 2</th><th>Info 3</th></tr>";
if (mysql_num_rows($result) > 0) {

	for ($i = '0'; $row = mysql_fetch_array($result), $i <= mysql_num_rows($result); $i++) {
                	        //changes the background color of the row based on if the row is even or odd
                        $row_bg_color=($i % 2 == 0) ? "#e5e5e5" : "#ffffff";

                        echo "<tr onMouseOver=\"this.style.background= '#ffff99'\" onMouseOut=\"this.style.background= '$row_bg_color'\" style=\"background: $row_bg_color; border-top: solid 1px #000000\">";
                        echo "<td>" . $row['blade_ip'] . "</td>";
                        echo "<td>" . $row['port_num'] . "</td>";
                        echo "<td>" . $row['info_1'] . "</td>";
                        echo "<td>" . $row['info_2'] . "</td>";
                        echo "<td>" . $row['info_3'] . "</td>";
                        echo "</tr>";
	}
}
else {
	echo "Nothing found...";
}
echo "</table>";


//mysql_close($con);
?>
